import React, { useState } from 'react';
import instance from '../../request/axios';
 
const Index = () => {
  const [loading, setLoading] = useState(false);

  const id = '12213'
  const name = '测试'
  const price = 123
  const onPay = async () => {
    setLoading(true);
    instance.post('/api/pay', {
        id: id,
        name: name,
        price: price
    }).then(res => {
        console.log(res);
    })
  }

  return (
    <button disabled={loading} onClick={onPay}>
      {loading ? '支付中' : '支付'}
    </button>
  );
};
 
export default Index;